<template>
  <el-drawer v-model="isShowDrawer">
    <el-form v-bind="elFormProps">
      <slot></slot>
    </el-form>

    <template #footer>
      <slot name="footer">
        <el-button @click="test">测试</el-button>
        <el-button @click="cancel">取消</el-button>
        <el-button @click="confirm">确定</el-button>
      </slot>
    </template>
  </el-drawer>
</template>

<script lang="ts" setup>
// TODO
import NodeDrawerWrapper from "@/views/workTable/components/nodeDrawer/NodeDrawer.vue";
import {IFormValidateResult} from "@/views/workTable/types/nodeDrawer";

const props = defineProps<{
  elFormProps: object
}>()
const emits = defineEmits(['update:show', 'confirm', 'cancel'])
defineExpose(['validateForm'])


// const isShowDrawer = computed({
//   set(val) {
//     emits('update:show', val)
//   },
//   get() {
//     return props.show
//   }
// })

// Other Method Ref ....

// 业务方法
const test = () => {
  console.log('example drawer test method called.')
}

const cancel = () => {
}

const confirm = () => {
  // 一些业务逻辑
  // 一些业务逻辑
  // 一些业务逻辑
  // 一些业务逻辑
  // 一些业务逻辑

  emits('confirm', {
    dialogData: '修改后的表单或业务数据',
    formValidateResult: {result: true, message: '验证通过'}
  })
}

const validateForm: () => IFormValidateResult = () => {
  return {result: true, message: '表单校验结果：成功/失败'}
}
</script>

<style scoped lang="scss">

</style>
